<template>
  <div class="comBox">
    <div class="title">哈尔滨学院在线食堂管理系统</div>
    <div class="loginB"></div>
    <el-form
      :model="ruleForm"
      status-icon
      ref="ruleForm"
      label-width="100px"
      class="login"
    >
      <el-form-item label="账号" prop="user">
        <el-input v-model="ruleForm.user"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="pass">
        <el-input type="password" v-model="ruleForm.pass"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm">登录</el-button>
        <!-- <el-button @click="$router.push(`/register`)">注册</el-button> -->
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      ruleForm: {
        user: ``,
        pass: ``,
      },
    }
  },
  methods: {
    async submitForm() {
      const form = {
        user: this.ruleForm.user,
        pass: this.ruleForm.pass,
      }
      const user = await this.$http.instance.post(`/login`, form)
      this.$store.state.user = user
      localStorage.setItem(`user`, JSON.stringify(user))
      this.$router.push(`/statistics`)
    },
  },
}
</script>

<style lang="less" scoped>
.comBox {
  background: url(../../../static/beijing.webp);
  background-repeat: no-repeat;
  box-sizing: border-box;
  // width: 500px;
  // border: 1px solid red;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  .title {
    position: fixed;
    top: 80px;
    font-size: 50px;
    letter-spacing: 6px;
    color: white;
  }
  .loginB {
    background: white;
    box-shadow: 0.1px 0.5px 0.5px 1px;
    border-radius: 12px;
    position: absolute;
    // border: 1px solid red;
    height: 220px;
    width: 320px;
  }
  .login {
    z-index: 999;
    // height: 500px;
    // width: 500px;
  }
}
</style>
